﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FichoWeb.Common;

namespace FichoWeb.Models
{
    public class User
    {
        public User()
        {
            this.Comments = new HashSet<Comment>();
        }

        public int Id { get; set; }

        private string _Username;
        public string Username
        {
            get
            {
                return _Username;
            }
            set
            {
                _Username = value.ToLower();
            }
        }

        private string _Password;
        public string Password
        {
            get
            {
                return _Password;
            }
            set
            {
                _Password = value.ToSHA();
            }
        }
        
        private string _Role;
        public string Role
        {
            get { return _Role; }
            set { _Role = value.ToLower(); }
        }

        public Nullable<DateTime> LastLogin { get; set; }
        public Nullable<bool> Active { get; set; }

        public virtual ICollection<Comment> Comments { get; set; }
    }
}